function HandleFindDesigner(gui, operator, now, options) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  this._options = options;
  this._deadLine = (options && options.a) ? options.a : null;
  this._m = (options && options.m) ? options.m : null;
  
  this._createElements();
};

HandleFindDesigner.prototype._createElements = function() {
  this._loadData();
};

HandleFindDesigner.prototype._loadData = function() {
  this._designers = null;
  this._retrieveDesigners();
};

HandleFindDesigner.prototype._verifyData = function() {
  if (this._designers) {
    this._updateElements();
  }
};

HandleFindDesigner.prototype._retrieveDesigners = function() {
  var _self = this;
  /*new RequestUtils()._read('user', null, 'd.type = \'{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}\'', null, null, 'd.type', null, function(result, params) { _self._designers = result.data;
                                                                                                                                                                       _self._verifyData.call(_self);
                                                                                                                                                                     }, {php: Constant.FACTORY + '/jsonread.php'});
*/
var args = '&c=u.type = \'{{$smarty.const.USER_TYPE_DESIGNER|escape:javascript}}\'  AND u.isdisplay = 0';
  new RequestUtils()._mysql('v1user', args, function(result, params) { _self._designers = result.data;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:Constant.FACTORY + '/customphp/mysqlread.php'});       
};

HandleFindDesigner.prototype._updateElements = function() {
  var tr, td, _self = this;
  
  var path = '';
  if (this._operator.type == '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}') {
    path = 'pageasst';
    s = 2;
    menu1 = JSON.stringify({a:1,b:2,c:1});
    menu2 = JSON.stringify({a:1,b:2,c:2});
    menu3 = JSON.stringify({a:1,b:2,c:3});
    menu4 = JSON.stringify({a:1,b:2,c:4});
    menu5 = JSON.stringify({a:1,b:2,c:5});
    menu6 = JSON.stringify({a:1,b:2,c:6});
  } else if (this._operator.type == '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}') {
    path = 'pagemanager';
    if (this._deadLine) {
      s = 0;
      menu1 = JSON.stringify({a:1,b:3,c:1,d:3});
      menu2 = JSON.stringify({a:1,b:3,c:2,d:3});
      menu3 = JSON.stringify({a:1,b:3,c:3,d:3});
      menu4 = JSON.stringify({a:1,b:3,c:4,d:3});
      menu5 = JSON.stringify({a:1,b:3,c:5,d:3});
      menu6 = JSON.stringify({a:1,b:3,c:6,d:3});
    } else {
      s = 3;
      menu1 = JSON.stringify({a:1,b:2,c:1});
      menu2 = JSON.stringify({a:1,b:2,c:2});
      menu3 = JSON.stringify({a:1,b:2,c:3});
      menu4 = JSON.stringify({a:1,b:2,c:4});
      menu5 = JSON.stringify({a:1,b:2,c:5});
      menu6 = JSON.stringify({a:1,b:2,c:6});
    }
  } else if (this._operator.type == '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}') {
    path = 'pageserv';
    s = 1;
    menu1 = JSON.stringify({a:1,b:2,c:1});
    menu2 = JSON.stringify({a:1,b:2,c:2});
    menu3 = JSON.stringify({a:1,b:2,c:3});
    menu4 = JSON.stringify({a:1,b:2,c:4});
    menu5 = JSON.stringify({a:1,b:2,c:5});
    menu6 = JSON.stringify({a:1,b:2,c:6});
  } else {
    path = 'pageadmin';
    s = 4;
    menu1 = JSON.stringify({a:2,b:3,c:1,d:3,e:3});
    menu2 = JSON.stringify({a:2,b:3,c:2,d:3,e:3});
    menu3 = JSON.stringify({a:2,b:3,c:3,d:3,e:3});
    menu4 = JSON.stringify({a:2,b:3,c:4,d:3,e:3});
    menu5 = JSON.stringify({a:2,b:3,c:5,d:3,e:3});
    menu6 = JSON.stringify({a:2,b:3,c:6,d:3,e:3});
  }
  if (this._m == 1) {
    var query = DlmanageUtils.designerTasks;
  } else if (this._m == 2) {
    query = DlmanageUtils.designerCompleteDesign;
  } else if (this._m == 3) {
    query = DlmanageUtils.designerModifyDesign;
  } else if (this._m == 4) {
    query = DlmanageUtils.designerDownloadChange;
  } else if (this._m == 5) {
    query = DlmanageUtils.designerPhoto4x6;
  } else if (this._m == 6) {
    query = DlmanageUtils.designerUploadDesign;
  }
  
  if (this._designers.length == 0) {
    this._gui.div.style.display = 'block';
    var u = { trackId: '0' };
    var smryGui = GuiSmryDesigner.instance();
    var menu = GuiSmryDesignerMenu.instance();
    this._query = query + ' AND d.user_trackId = \'' + u.trackId + '\'';
    var smryArgs = DlmanageUtils.desSmryArgs(smryGui, u);
    
    menu.designerTasksTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1designerworks&m=' + menu1 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 1, trackId: _self._options.trackId});};
    menu.designTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1completedesign&m=' + menu2 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 2, trackId: _self._options.trackId});};
    menu.designChangeTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1modifydesign&m=' + menu3 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 3, trackId: _self._options.trackId});};
    menu.photoTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1downloadchange&m=' + menu4 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 4, trackId: _self._options.trackId});};
    menu.send4x6Td.onclick = function() {location.href = '?p=' + path + '&t=pageb1photo4x6&m=' + menu5 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 5, trackId: _self._options.trackId});};
    menu.uploadDesignTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1uploaddesign&m=' + menu6 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 6, trackId: _self._options.trackId});};
    
  } else {
    this._gui.div.style.display = 'block';
    var gui = GuiSmryAsst.instance();
    DOMUtils.removeChildElements(gui.menusTable);
    if (this._operator.type != '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}') {
      gui.menusTable.style.borderRight = 'solid 1px #8c908c';
      gui.menusTable.style.borderBottom = 'solid 1px #8c908c';
    }
    var smryGui = GuiSmryDesigner.instance();
    var menu = GuiSmryDesignerMenu.instance();

    if (this._options.trackId) {
      for(var i = 0, il = this._designers.length; i < il; i++) {
        var u = this._designers[i];
        if (u.trackId == this._options.trackId) {
          this._query = query + ' AND d.user_trackId = \'' + u.trackId + '\'';
          var smryArgs = DlmanageUtils.desSmryArgs(smryGui, u);
        }
      }
    } else {
      this._query = query + ' AND d.user_trackId = \'' + this._designers[0].trackId + '\'';
      var smryArgs = DlmanageUtils.desSmryArgs(smryGui, this._designers[0]);
    }
    
    menu.designerTasksTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1designerworks&m=' + menu1 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 1, trackId: _self._options.trackId});};
    menu.designTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1completedesign&m=' + menu2 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 2, trackId: _self._options.trackId});};
    menu.designChangeTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1modifydesign&m=' + menu3 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 3, trackId: _self._options.trackId});};
    menu.photoTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1downloadchange&m=' + menu4 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 4, trackId: _self._options.trackId});};
    menu.send4x6Td.onclick = function() {location.href = '?p=' + path + '&t=pageb1photo4x6&m=' + menu5 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 5, trackId: _self._options.trackId});};
    menu.uploadDesignTd.onclick = function() {location.href = '?p=' + path + '&t=pageb1uploaddesign&m=' + menu6 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._options.a, d: _self._options.d, m: 6, trackId: _self._options.trackId});};
    
    tr = gui.menusTable.insertRow(-1);
    for(var i = 0, il = this._designers.length; i < il; i++) {
      var u = this._designers[i];
      
      if(this._operator.type == '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}')
      {
	      if(u.account == 'jiangnan' || u.account == 'factory' || u.account == 'admin')
	      {
	         continue;
	      }
      }
      
      td = tr.insertCell(-1);
      td.style.textAlign = 'center';
      td.style.verticalAlign = 'middle';
      td.style.height = '25px';
      var span = document.createElement('span');
      span.style.margin = '0 10px';
      span.style.cursor = 'pointer';
      span.style.fontSize = '12px';
      span.style.fontWeight = 'bold';
      span._index = i;
      span._u = u;
      span.className = "designer";
      span.style.color = (this._options.d == i+1) ? '#694247' : '';
      span.appendChild(document.createTextNode((u.account).substring(0,1).toUpperCase() + (u.account).substring(1)));
      span.onclick = function() {location.href = '?p=' + path + '&t=pageb1designerworks&m=' + menu1 + '&s=' + JSON.stringify({s:s}) + '&opts=' + JSON.stringify({a: _self._deadLine, d: parseInt(this._index+1), m: 1, trackId: this._u.trackId});};
      td.appendChild(span);
    }
  }
  if (this._designers && query != 'undefined ') {
    var manager = (this._operator.type == '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}') ? true : false;
    var gui = GuiProduces.instance(this._gui.customerNo, this._gui.task, this._gui.search, this._gui.updated, this._gui.pages, this._gui.tasks);
    new HandleProduces(gui, null, { operator: this._operator, now: this._now, query: this._query, smryGui: smryGui, smryArgs: smryArgs, a: this._options.a, s: 1, manager: manager});
  }
};
